﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ZG_member.Model;
using System.Data.SqlClient;
using System.Data;
using Maticsoft.DBUtility;
namespace ZG_member.DAL
{
    public class SMS
    {

        public bool add(ZG_member.Model.SMS model)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("insert into goodsInfo(");
            strSql.Append("SMSjifen,SMSneirong)");
            strSql.Append("values (");
            strSql.Append("@SMSjifen,@SMSneirong)");
            SqlParameter[] parameters = {
					 
					new SqlParameter("@SMSjifen", SqlDbType.NVarChar,50),
					new SqlParameter("@SMSneirong", SqlDbType.NVarChar,500)
					};

            parameters[0].Value = model.SMSjifen1;
            parameters[1].Value = model.SMSneirong1;
            object obj = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);

            if (obj == null)
            {
                return false;
            }
            else
            {
                return true;
            }
        }



        public Model.SMS GetListmodel()
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select *");
            strSql.Append(" FROM SMS");
            DataSet ds = DbHelperSQL.Query(strSql.ToString());
            ZG_member.Model.SMS model = new ZG_member.Model.SMS();
            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["id"] != null && ds.Tables[0].Rows[0]["id"].ToString() != "")
                {
                    model.Id = int.Parse(ds.Tables[0].Rows[0]["id"].ToString());
                }
                if (ds.Tables[0].Rows[0]["SMSjifen"] != null && ds.Tables[0].Rows[0]["SMSjifen"].ToString() != "")
                {
                    model.SMSjifen1 = ds.Tables[0].Rows[0]["SMSjifen"].ToString();
                }
                if (ds.Tables[0].Rows[0]["SMSneirong"] != null && ds.Tables[0].Rows[0]["SMSneirong"].ToString() != "")
                {
                    model.SMSneirong1 = ds.Tables[0].Rows[0]["SMSneirong"].ToString();
                }
                
                return model;
            }
            else
            {
                return null;
            }
        }


        public bool update(Model.SMS modle) {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("update SMS set ");
            strSql.Append("SMSjifen=@SMSjifen,");
            strSql.Append("SMSneirong=@SMSneirong");
            SqlParameter[] parameters = {
					new SqlParameter("@SMSjifen", SqlDbType.NVarChar,50),
					new SqlParameter("@SMSneirong", SqlDbType.NVarChar,500)};
            parameters[0].Value = modle.SMSjifen1;
            parameters[1].Value = modle.SMSneirong1;
 

            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
            if (rows > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        
        }








    }
}
